package chapter5;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description: 计算平均值和标准方差
 * Date:2021/4/4
 * ***************************************************************
 */
public class exc5_45 {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		System.out.print("Enter ten numbers: ");
		double[] darray= {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0};
		double sum=0;
		double sumQ=0;
		for(int i=0;i<10;i++) {
			darray[i]=input.nextDouble();
			sum+=darray[i];
			sumQ+=Math.pow(darray[i], 2);
		}
		double avg=sum/10.0;
		
		
		//计算方差
		double variance=Math.sqrt((sumQ-Math.pow(sum, 2)/10.0)/(10.0-1.0));
		
		System.out.printf("The mean is %.2f\nThe standard deviation is  %.5f\n",avg,variance);
		
		
		
	}

}
